package com.jlf.controller.engine.entity.criterion;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jlf.core.engine.domain.SchemaCriterionDO;
import com.jlf.core.server.entity.Q;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

/**
 * 模型领域的检索条件的查询条件
 *
 * @author wujr
 * 2023/7/28
 * @version 1.0
 * 【变更历史】
 * [wujr 2023/7/28 1.0 新增]
 */
@Getter
@Setter
public class SchemaCriterionQueryInput implements Q<SchemaCriterionDO> {
    private String domainCode;
    private String key;
    /**
     * 是否支持eq查询，默认：true
     */
    private Boolean supportEqual;
    /**
     * 是否支持ne查询，默认：false
     */
    private Boolean supportNotEqual;
    /**
     * 是否支持大于等于，默认：false
     */
    private Boolean supportGreatEqual;
    /**
     * 是否支持大于，默认：false
     */
    private Boolean supportGreatThan;
    private Boolean supportLessThan;
    private Boolean supportLessEqual;
    /**
     * 是否支持like查询，仅针对varchar的字段有效，默认：false，对于varchar字段，默认：true
     */
    private Boolean supportLike;
    /**
     * 是否支持notLike查询，仅针对varchar的字段有效，默认：false
     */
    private Boolean supportNotLike;
    private Boolean supportLikeLeft;
    private Boolean supportLikeRight;
    private Boolean supportNotLikeLeft;
    private Boolean supportNotLikeRight;

    @Override
    public void build(QueryWrapper<SchemaCriterionDO> wrapper) {
        Integer supportCriterion = null;

        wrapper.lambda().like(!StringUtils.isBlank(domainCode), SchemaCriterionDO::getDomainCode, domainCode)
                .like(!StringUtils.isBlank(key), SchemaCriterionDO::getClassFieldCode, key)
                .orderByAsc(SchemaCriterionDO::getDomainCode)
                .orderByAsc(SchemaCriterionDO::getPriority);
    }
}
